//
//  MainNavViewController.swift
//  微博（swift）
//
//  Created by 谢曦 on 2017/5/4.
//  Copyright © 2017年 谢曦. All rights reserved.
//

import UIKit

class MainNavViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
      navigationBar.tintColor=UIColor.white
//        navigationBar.titleTextAttributes=[NSForegroundColorAttributeName:UIColor.orange]
    }
    func back()  {
        popViewController(animated: true)
    }
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
       
        print(viewController)
        print(viewControllers)
        
        if viewControllers.count>0 {
            viewController.hidesBottomBarWhenPushed=true
            
            //当只有一级的时候 显示箭头
            // 其余显示箭头加文字
            if viewControllers.count==1 {
               viewController.navigationItem.leftBarButtonItem=UIBarButtonItem.init(themeBackArrowWithTarget: self, action: #selector(back))
            }
            else {
                let vc = viewControllers.last
                viewController.navigationItem.leftBarButtonItem=UIBarButtonItem.init(themeBtnTitle: vc?.title, image: "navigationbar_back_withtext_highlighted", target: self, action: #selector(back))
                          }
        }
        else{
            //在栈底
            
         viewController.hidesBottomBarWhenPushed=false
        }
         super.pushViewController(viewController, animated: animated)
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
